import { Controller, Get, Inject } from '@nestjs/common';
import { AppService } from './app.service';
import { ClientProxy } from '@nestjs/microservices';
import { timeout } from 'rxjs'; 
import { InjectModel } from '@nestjs/sequelize'; 
import { UserService } from './user/user.service';


@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Inject('COMMON_SERVICE')
  private commonServiceClient: ClientProxy

  @Inject()
  private userService: UserService

  @Get('say')
  async getHello(): Promise<string> {
    
     const ret = await this.userService.findAll()
    console.log('查询结果', ret)
    const result = await this.commonServiceClient.send<string, string>({ cmd: 'sum2' }, '123').pipe(timeout(1000)).toPromise()
    return result
  }
}
